<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla controller library
jimport('joomla.application.component.controller');
 
/**
 * Hello World Component Controller
 */
class BookingControllerGetdata extends JController
{
	function identify()
	{
		$user = JFactory::getUser();
		$r['name'] = $user->username;
		$r['id'] = $user->id;
		echo json_encode($r);
	}
	function resource_type()
	{
		echo "<select id=\"res_type\">
			<option value=\"Free\">免費會議室</option>
			<option value=\"Charge\">收費會議室</option>
		</select>";
	}
	function getResverations(){
		JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_booking'.DS.'tables');
		$r = JRequest::get( 'get' );
		//$json = json_decode($r['content']);
		$table =  JTable::getInstance('reservations', 'Table');
		//$rows = $table->getReservations($json->resource_id,$json->start_time,$json->end_time);
		$rows = $table->getReservations($r['resource_id'],$r['start_time'],$r['end_time']);
		echo json_encode($rows);
		
	}
	function test()
	{
		$json = JRequest::get( 'post' );
		//echo $json;
		echo json_encode($json);
	}
}
?>